/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "CMSRole", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "CMSRole.findAll", query = "SELECT c FROM CMSRole c"),
    @NamedQuery(name = "CMSRole.findByRoleId", query = "SELECT c FROM CMSRole c WHERE c.roleId = :roleId"),
    @NamedQuery(name = "CMSRole.findByRoleName", query = "SELECT c FROM CMSRole c WHERE c.roleName = :roleName"),
    @NamedQuery(name = "CMSRole.findByDescription", query = "SELECT c FROM CMSRole c WHERE c.description = :description")})
public class CMSRole implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "RoleId", nullable = false)
    private Integer roleId;
    @Basic(optional = false)
    @Column(name = "RoleName", nullable = false, length = 50)
    private String roleName;
    @Column(name = "Description", length = 100)
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cMSRole", fetch = FetchType.EAGER)
    private List<Account> accountList;

    public CMSRole() {
    }

    public CMSRole(Integer roleId) {
        this.roleId = roleId;
    }

    public CMSRole(Integer roleId, String roleName) {
        this.roleId = roleId;
        this.roleName = roleName;
    }

    public Integer getRoleId() {
        return roleId;
    }

    public void setRoleId(Integer roleId) {
        this.roleId = roleId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public List<Account> getAccountList() {
        return accountList;
    }

    public void setAccountList(List<Account> accountList) {
        this.accountList = accountList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (roleId != null ? roleId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CMSRole)) {
            return false;
        }
        CMSRole other = (CMSRole) object;
        if ((this.roleId == null && other.roleId != null) || (this.roleId != null && !this.roleId.equals(other.roleId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entity.CMSRole[roleId=" + roleId + "]";
    }

}
